#pragma once

// include all the states
#include "IBaseState.h"
#include "CMainMenuState.h"
#include "CMotionPlusCalibrateState.h"
#include "CGameState.h"

class IBaseState;
class CDirect3D;
class CRetroInput;
class CStateMachine
{
private: // singleton
	CStateMachine(void);
	~CStateMachine(void);
	CStateMachine(const CStateMachine*);
	CStateMachine& operator=(const CStateMachine*);

	static CStateMachine* m_pInstance;
public: // singleton
	static CStateMachine* GetInstance();
	static void FreeInstance();

private: // data structure
	struct StateObject
	{
		IBaseState* pState;
		StateObject* pNext;
	};
	StateObject* m_pTopState;
public: // functions

	// state related
	void Initialize();
	void Shutdown();
	void PushState(IBaseState* pState);
	void ChangeState(IBaseState* pState);
	void FlushStates();
	void PopState();

	// runtime related
	void Update(float fDeltaTime);
	void Input(CRetroInput* pInput);
	void Render(CDirect3D* pRender);

};

